/*
 * @Author: czy
 * @Date: 2021-04-23 16:00:20
 * @LastEditTime: 2021-07-15 10:08:44
 */
#include "stdio.h"
#include "stdlib.h"
#include "process.h"

#include "sys/system.h"

#define SLEEP for (int i = 0; i < 10000; i++)\
                for (int j = 0; j < 10000; j++)\
                    ;

int tsk1(void)
{
    SLEEP
    printf("* \033[32m         tsk1-01          \033[0m*\n");
    SLEEP
    printf("* \033[32m         tsk1-02          \033[0m*\n");
    SLEEP
    printf("* \033[32m         tsk1-03          \033[0m*\n");
    exit(0);
}

int tsk2(void)
{
    SLEEP
    printf("* \033[33m         tsk2-01          \033[0m*\n");
    SLEEP
    // printf("* \033[33m        tsk2-02         \033[0m*\n");
    printf("* \033[33mtry to raise an exception \033[0m*\n");
    int i = 0, j = 1;
    i = j / i;
    printf("* \033[33m         tsk2-03          \033[0m*\n");
    exit(0);
}

int tsk3(void)
{
    SLEEP
    printf("* \033[34m         tsk3-01          \033[0m*\n");
    SLEEP
    printf("* \033[34m         tsk3-02          \033[0m*\n");
    SLEEP
    printf("* \033[34m         tsk3-03          \033[0m*\n");
    exit(0);
}

int main(void)
{
    tskStart(createTsk(tsk1));
    tskStart(createTsk(tsk2));
    tskStart(createTsk(tsk3));
    shell();
    return 0;
}
